Skip to content

[BugFix] Seperate prometheus multiproc dir for single-server multi-dp services#8059

Open
liyonghua0910 wants to merge 2 commits into
PaddlePaddle:developfrom
liyonghua0910:develop+20260616_fix_dp_metrics
Open

[BugFix] Seperate prometheus multiproc dir for single-server multi-dp services#8059
liyonghua0910 wants to merge 2 commits into
PaddlePaddle:developfrom
liyonghua0910:develop+20260616_fix_dp_metrics

Conversation

@liyonghua0910

Copy link
Copy Markdown
Collaborator

Motivation

💡 If this PR is a Cherry Pick, the PR title needs to follow the format by adding the [Cherry-Pick] label at the very beginning and appending the original PR ID at the end. For example, [Cherry-Pick][CI] Add check trigger and logic(#5191)

💡 如若此PR是Cherry Pick,PR标题需遵循格式,在最开始加上[Cherry-Pick]标签,以及最后面加上原PR ID,例如[Cherry-Pick][CI] Add check trigger and logic(#5191)

Modifications

Usage or Command

Accuracy Tests

Checklist

  • Add at least a tag in the PR title.
    • Tag list: [[FDConfig],[APIServer],[Engine], [Scheduler], [PD Disaggregation], [Executor], [Graph Optimization], [Speculative Decoding], [RL], [Models], [Quantization], [Loader], [OP], [KVCache], [DataProcessor], [BugFix], [Docs], [CI], [Optimization], [Feature], [Benchmark], [Others], [XPU], [HPU], [GCU], [DCU], [Iluvatar], [Metax]]
    • You can add new tags based on the PR content, but the semantics must be clear.
  • Format your code, run pre-commit before commit.
  • Add unit tests. Please write the reason in this PR if no unit tests.
  • Provide accuracy results.
  • If the current PR is submitting to the release branch, make sure the PR has been submitted to the develop branch, then cherry-pick it to the release branch with the [Cherry-Pick] PR tag.

@codecov-commenter

codecov-commenter commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.67568% with 9 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@cbb0811). Learn more about missing BASE report.

Files with missing lines Patch % Lines
fastdeploy/engine/engine.py 16.66% 5 Missing ⚠️
fastdeploy/engine/common_engine.py 33.33% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #8059   +/-   ##
==========================================
  Coverage           ?   67.22%           
==========================================
  Files              ?      475           
  Lines              ?    66884           
  Branches           ?    10317           
==========================================
  Hits               ?    44961           
  Misses             ?    19051           
  Partials           ?     2872           
Flag Coverage Δ
GPU 77.22% <75.67%> (?)
XPU 6.96% <35.13%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

PaddlePaddle-bot

This comment was marked as outdated.

PaddlePaddle-bot

This comment was marked as outdated.

@PaddlePaddle-bot

PaddlePaddle-bot commented Jun 18, 2026

Copy link
Copy Markdown

🤖 Paddle-CI-Agent | ci_status_monitor | 2026-06-22 11:13:27 UTC+08:00

CI报告基于以下代码生成(30分钟更新一次):
PR commit: 06130f1 | Merge base: cbb0811 (branch: develop)


1 Required任务 : 3/10 通过

总执行(rerun次数) 总任务 ✅ 通过 ❌ 失败 ⏳ 运行中 ⏸️ 等待中 跳过
38(0) 38 26 3 6 3 0
任务 错误类型 置信度 日志
Approval 需要 Approval Job

2 失败详情

🔴 Approval — 需要 Approval(置信度: 高)

该 Job 需要人工 Approval,完成审批后 CI 才会继续执行。

修复建议:请通过人工审批。

PaddlePaddle-bot

This comment was marked as outdated.

PaddlePaddle-bot

This comment was marked as outdated.

@PaddlePaddle-bot PaddlePaddle-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Paddle-CI-Agent | pr_review | 2026-06-22 11:03:00

📋 Review 摘要

PR 概述:为多 DP 服务拆分 Prometheus multiprocess 目录,避免多个 DP 共享同一指标目录。
变更范围fastdeploy/metricsfastdeploy/engine、OpenAI multi API server 与相关测试。
影响面 Tag[Engine] [APIServer]

问题

级别 文件 概述
🔴 Bug fastdeploy/metrics/prometheus_multiprocess_setup.py:47 用户指定的 multiprocess 目录被静默复用,旧 .db 会继续参与采集并污染 DP0 指标

历史 Findings 修复情况

Finding 问题 状态
F1 engine.py 切到 dp0/metrics 仍只采集当前环境变量目录 ⚠️ 仍存在
F2 common_engine.py 启动路径也切到 dp0,但 metrics HTTP 入口未支持多个 DP 子目录 ⚠️ 仍存在

📝 PR 规范检查

PR 标题 tag 符合规范,但描述各章节仍是模板占位内容,建议替换为下面可复制版本。

标题建议(可直接复制):

  • [BugFix] Separate prometheus multiproc dir for single-server multi-dp services
PR 描述建议(点击展开,可直接复制)
## Motivation
修复单 API server 多 DP 部署中 Prometheus multiprocess 目录共享导致 Counter/Histogram 指标容易混淆的问题。

## Modifications
- `fastdeploy/metrics/prometheus_multiprocess_setup.py`: 新增 `setup_dp_prometheus_dir`,按 DP id 创建独立的 Prometheus multiprocess 目录。
- `fastdeploy/engine/engine.py``fastdeploy/engine/common_engine.py`: 启动 DP 子服务前切换到对应 DP 的 `PROMETHEUS_MULTIPROC_DIR`,子服务启动后切回 DP0 目录。

## Usage or Command
N/A

## Accuracy Tests
N/A(仅调整 metrics multiprocess 目录,不影响模型精度)

## Checklist

- [x] Add at least a tag in the PR title.
  - Tag list: [`[FDConfig]`,`[APIServer]`,`[Engine]`, `[Scheduler]`, `[PD Disaggregation]`, `[Executor]`, `[Graph Optimization]`, `[Speculative Decoding]`, `[RL]`, `[Models]`, `[Quantization]`, `[Loader]`, `[OP]`, `[KVCache]`, `[DataProcessor]`, `[BugFix]`, `[Docs]`, `[CI]`, `[Optimization]`, `[Feature]`, `[Benchmark]`, `[Others]`, `[XPU]`, `[HPU]`, `[GCU]`, `[DCU]`, `[Iluvatar]`, `[Metax]`]
  - You can add new tags based on the PR content, but the semantics must be clear.
- [ ] Format your code, run `pre-commit` before commit.
- [ ] Add unit tests. Please write the reason in this PR if no unit tests.
- [ ] Provide accuracy results.
- [ ] If the current PR is submitting to the `release` branch, make sure the PR has been submitted to the `develop` branch, then cherry-pick it to the `release` branch with the `[Cherry-Pick]` PR tag.

总体评价

目录隔离方向合理,但当前实现仍没有补上单 server 多 DP 子目录的聚合采集,历史两个指标完整性问题仍存在;同时本次把用户指定 multiprocess 目录从 warning 改为静默复用,会让陈旧 .db 文件继续污染本轮 metrics。建议先修正目录生命周期和多 DP 采集语义后再合入。


user_dir = os.environ["PROMETHEUS_MULTIPROC_DIR"]
_original_prom_dir = user_dir
os.makedirs(user_dir, exist_ok=True)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Bug 这里在用户传入的 PROMETHEUS_MULTIPROC_DIR 上直接 os.makedirs(..., exist_ok=True) 并继续复用目录,但没有清理已有 .db 文件。

get_filtered_metrics() 仍会通过 multiprocess.MultiProcessCollector 读取当前目录里的所有 .db,而后续 setup_dp_prometheus_dir(0, base_dir) 还会把 base 目录下的旧 .db 迁到 dp0/。固定复用同一个目录或服务异常退出后,上一轮进程的 counter/histogram 会被当成本轮 DP0 指标采集,PR 反而会静默产生不准确 metrics;旧代码至少会 warning 这个风险。

建议修复方式:在注册 metrics 前保证本轮使用的 base/dp* 目录没有旧 .db,例如为用户目录再创建带 UUID 的 run 子目录作为 base_dir,或显式删除 base 与对应 dp{i} 子目录中的 .db;如果不打算接管用户目录清理,则保留 warning/校验并拒绝非空目录。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants